﻿<phone:PhoneApplicationPage x:Class="USElections.CandidatePage.Pages.CandidatePage"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                            xmlns:conv="clr-namespace:USElections.Converters;assembly=USElections.Converters"
                            xmlns:nlcontrols="clr-namespace:NorthernLights.Controls;assembly=NorthernLights.Controls"
                            xmlns:tsconv="clr-namespace:USElections.TwitterLibrary.Converters;assembly=USElections.TwitterLibrary"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            SupportedOrientations="Portrait"
                            Orientation="Portrait"
                            mc:Ignorable="d"
                            d:DesignHeight="768"
                            d:DesignWidth="480"
                            shell:SystemTray.IsVisible="True"
                            shell:SystemTray.Opacity="0"
                            Style="{StaticResource TransitionPageStyle}">
    <phone:PhoneApplicationPage.Resources>
        <conv:ToLowerCaseConverter x:Key="tolower" />
        <conv:PartyToColorConverter x:Key="ptc" />
        <tsconv:TweetStatusConverter x:Key="tsconv" />
    </phone:PhoneApplicationPage.Resources>

    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator IsIndeterminate="True"
                                 IsVisible="False"
                                 Text="Downloading..." />
    </shell:SystemTray.ProgressIndicator>

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <controls:Panorama x:Name="panaromaCtrl"
                           Grid.Row="0"
                           Title="{Binding FullName, Converter={StaticResource tolower}}">
            <controls:Panorama.Background>
                <ImageBrush ImageSource="/Images/whitehouse.jpg"
                            Opacity="0.35"
                            AlignmentY="Top"
                            Stretch="None" />
            </controls:Panorama.Background>

            <controls:PanoramaItem Header="info">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <ScrollViewer>
                        <StackPanel>
                            <TextBlock Text="{Binding FullName}"
                                       Style="{StaticResource PhoneTextExtraLargeStyle}" />
                            <StackPanel Orientation="Horizontal"
                                        Margin="18, 6, 0, 6">
                                <Rectangle Fill="{Binding Party, Converter={StaticResource ptc}}"
                                           Width="24"
                                           Height="24"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Center" />
                                <TextBlock Text="{Binding Party, StringFormat='{0} Party'}"
                                           Style="{StaticResource PhoneTextNormalStyle}" />
                            </StackPanel>
                        </StackPanel>
                    </ScrollViewer>
                </Grid>
            </controls:PanoramaItem>

            <controls:PanoramaItem x:Name="twitterPanorama"
                                   Visibility="Collapsed"
                                   Header="twitter">
                <Grid x:Name="twitterGrid">
                    <ListBox ItemsSource="{Binding TimeLine}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="12,10,2,2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="79"></ColumnDefinition>
                                        <ColumnDefinition Width="*"></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"></RowDefinition>
                                    </Grid.RowDefinitions>

                                    <Image VerticalAlignment="Top"
                                           Margin="0,6"
                                           Grid.Column="0"
                                           Source="{Binding ProfileImageUrl}"
                                           Width="73"
                                           Height="73" />

                                    <StackPanel Grid.Column="1"
                                                Orientation="Vertical">
                                        <TextBlock Text="{Binding ScreenName}"
                                                   Style="{StaticResource PhoneTextNormalStyle}"
                                                   FontWeight="Bold" />
                                        <ContentControl Content="{Binding Status, Converter={StaticResource tsconv}}" />
                                        <TextBlock Text="{Binding CreatedDate}"
                                                   Style="{StaticResource PhoneTextSmallStyle}" />
                                    </StackPanel>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                    <nlcontrols:Notification x:Name="notification" />
                </Grid>
            </controls:PanoramaItem>
        </controls:Panorama>
    </Grid>
</phone:PhoneApplicationPage>